﻿namespace CachePage
{
    using System;
    using System.Web.UI;
    using System.Web.UI.Adapters;

    public class ScriptManagerAdapter : ControlAdapter
    {
        protected override void OnInit(EventArgs e)
        {
            if (base.Page.PageAdapter is PageStateAdapter)
            {
                PageStateAdapter pageAdapter = (PageStateAdapter) base.Page.PageAdapter;
                if (pageAdapter.IsExtensionsPage)
                {
                    foreach (string str in ExtensionsConfigSection.GetCachePageScriptList())
                    {
                        ScriptReference item = new ScriptReference("~" + str);
                        ((ScriptManager) base.Control).Scripts.Add(item);
                    }
                }
            }
            base.OnInit(e);
        }
    }
}

